package com.UKIT.airtickets.DB

import androidx.room.Dao
import androidx.room.Insert
import androidx.room.Query
import androidx.room.Update

@Dao
interface UserFavoriteDao {
    @Query("SELECT * FROM user_favorites WHERE userId = :userId")
    fun getUserFavorites(userId: Long): List<UserFavorite>

    @Insert
    fun insertUserFavorite(userFavorite: UserFavorite)

    @Update
    fun updateUserFavorite(userFavorite: UserFavorite)

    @Query("DELETE FROM user_favorites WHERE id = :favoriteId")
    fun deleteUserFavorite(favoriteId: Long)

    @Query("SELECT COUNT(*) FROM user_favorites WHERE searchToken = :searchToken AND userId = :userId")
    fun isFavorite(searchToken: String, userId: Long): Int

    @Query("DELETE FROM user_favorites WHERE searchToken = :searchToken")
    fun deleteFavorite(searchToken: String)
}

